package com.analyse.stock.service.impl;

import com.analyse.stock.mapper.StockAnalyseFocusMapper;
import com.analyse.stock.model.StockAnalyseFocusModel;
import com.analyse.stock.service.IStockAnalyseFocus;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

@Slf4j
@Service
public class StockAnalyseFocusService extends ServiceImpl<StockAnalyseFocusMapper, StockAnalyseFocusModel> implements IStockAnalyseFocus {

    @Override
    public List<StockAnalyseFocusModel> getFocusList(StockAnalyseFocusModel model) {
        LambdaQueryWrapper<StockAnalyseFocusModel> wrapper = Wrappers.lambdaQuery();
        wrapper.ge(Objects.nonNull(model.getBuyType()),StockAnalyseFocusModel::getBuyType,model.getBuyType());
        wrapper.ge(Objects.nonNull(model.getScore()),StockAnalyseFocusModel::getScore,model.getScore());
        wrapper.le(Objects.nonNull(model.getPrice()),StockAnalyseFocusModel::getPrice,model.getPrice());
        wrapper.eq(Objects.nonNull(model.getStrategyCode()),StockAnalyseFocusModel::getStrategyCode,model.getStrategyCode());
        if(Objects.nonNull(model.getOccTime())){
            wrapper.ge(StockAnalyseFocusModel::getOccTime,model.getOccTime());
        }
        return super.list(wrapper);
    }
}
